import { FormSchema } from "/@/components/Form"

export const typeCons = {
  // 文本
  Text: {
    Input: { name: "Input", type: "1", title: "单行文本", desc: "可输入50字" },
    InputPassword: { name: "InputPassword", type: "2", title: "密码框" },
    InputTextArea: { name: "InputTextArea", type: "3", title: "多行文本", desc: "可输入600字" },
  },
  // 选项
  Select: {
    Checkbox: { name: "Checkbox", type: "10", title: "单选框", desc: "" },
  },
  // 其他
  Other: {
    ImageUpload: {
      name: "MyImageUpload",
      type: "20",
      title: "图片上传",
      desc: "",
      propsForm: [
        {
          field: "ifCode",
          label: "接口代码",
          component: "Input",
        },
      ] as FormSchema[],
    },
    DatePicker: { name: "DatePicker", type: "21", title: "日期选择", desc: "" },
    TimePicker: { name: "TimePicker", type: "22", title: "时间选择", desc: "" },
    WeekPicker: { name: "WeekPicker", type: "23", title: "周选择", desc: "" },
    // RangePicker: { name: 'RangePicker', type: '24', title: '日期选择', desc: '' },
    // InputTextArea: { name: 'InputTextArea', type: '3', title: '多行文本', desc: '可输入600字' },
    // InputTextArea: { name: 'InputTextArea', type: '3', title: '多行文本', desc: '可输入600字' },
  },
}

const componentMap = new Map<string, any>()

for (const key in typeCons) {
  for (const key2 in typeCons[key]) {
    componentMap.set(typeCons[key][key2].type, typeCons[key][key2].name)
  }
}

export const getComponentName = (type) => componentMap.get(type)
